<!--
 * @Author: zxh
 * @Email: 1271027008@qq.com
 * @Date: 2020-03-12 14:05:17
 * @Descripttion: 物料有效期定义
 -->
<div class="material_validity_container">
    <div nz-row nzGutter="16" style="padding:10px 0;">
        <div nz-col nzSpan="2">
            <button (click)="addEditMaterVali()" nzType="" nz-button [class]="numberOfChecked!==1?'ant-btn ant-btn-primary defaultBg disabledBg':'ant-btn ant-btn-primary defaultBg'" [disabled]="numberOfChecked!==1">保存</button>
        </div>
        <div nz-col nzSpan="6"></div>
        <div nz-col nzSpan="5">
            <label>物料编码：</label>
            <input class="width-70" appHotSearch (hotSearchEmit)="getMaterValiList('search')" nz-input placeholder="请输入物料编码" [(ngModel)]="materialCode" />
        </div>
        <div nz-col nzSpan="5">
            <label>物料名称：</label>
            <input class="width-70" appHotSearch (hotSearchEmit)="getMaterValiList('search')" nz-input placeholder="请输入物料名称" [(ngModel)]="materialName" />
        </div>
        <div nz-col nzSpan="6">
            <label nz-col nzSpan="8" style="display: inline-block;line-height: 32px;text-align: right;">材料类别：</label>
            <nz-select nzDropdownClassName="select_custom" nz-col nzSpan="16" [(ngModel)]="materialType" (ngModelChange)="selectMaterialType($event)">
                <nz-option nzValue="" nzLabel="-请选择-"></nz-option>
                <nz-option *ngFor="let item of materialTypeList" [nzValue]="item.value" [nzLabel]="item.label"></nz-option>
            </nz-select>
        </div>
    </div>
    <div nz-row class="table_row">
        <nz-table #rowSelectionTable [nzData]="listOfAllData" (nzCurrentPageDataChange)="currentPageDataChange($event)"
            [nzFrontPagination]="false" nzSize="small">
            <thead>
                <tr>
                    <th nzShowCheckbox [(nzChecked)]="isAllDisplayDataChecked" [nzIndeterminate]="isIndeterminate"
                        (nzCheckedChange)="checkAll($event)"></th>
                    <th>序号</th>
                    <th>物料编码</th>
                    <th>物料名称</th>
                    <th>材料类别</th>
                    <th>有效周期(天)</th>
                    <th>检验时长</th>
                    <th>复检周期</th>
                    <th>提醒周期(天)</th>
                    <th>是否复检</th>
                </tr>
            </thead>
            <tbody>
                <tr *ngFor="let data of rowSelectionTable.data;index as i">
                    <td nzShowCheckbox [(nzChecked)]="mapOfCheckedId[data.id]" [nzDisabled]="data.disabled"
                        (nzCheckedChange)="refreshStatus()"></td>
                    <td>{{ i+1 }}</td>
                    <td>{{ data.code }}</td>
                    <td>{{ data.name }}</td>
                    <td>{{ data.categoryName }}</td>
                    <td>
                        <span *ngIf="!checkedId.includes(data.id)">{{ data.validDay }}</span>
                        <input *ngIf="checkedId.includes(data.id)" nz-input placeholder="请输入有效周期" [(ngModel)]="data.validDay">
                    </td>
                    <td>
                        <span *ngIf="!checkedId.includes(data.id)">{{ data.validityConfig?data.validityConfig.checkDuration:'' }}</span>
                        <input *ngIf="checkedId.includes(data.id)" nz-input placeholder="请输入检验时长" [(ngModel)]="data.checkDuration" />
                    </td>
                    <td>
                        <span *ngIf="!checkedId.includes(data.id)">{{ data.validityConfig?data.validityConfig.checkCycle:'' }}</span>
                        <input *ngIf="checkedId.includes(data.id)" nz-input placeholder="请输入复检周期" [(ngModel)]="data.checkCycle" />
                    </td>
                    <td>
                        <span *ngIf="!checkedId.includes(data.id)">{{ data.validityConfig?data.validityConfig.remindDay:'' }}</span>
                        <input *ngIf="checkedId.includes(data.id)" nz-input placeholder="请输入提醒周期" [(ngModel)]="data.remindDay" />
                    </td>
                    <td>
                        <span *ngIf="!checkedId.includes(data.id)">{{ data.validityConfig?data.validityConfig.isRecheck?'是':'否':'' }}</span>
                        <nz-switch *ngIf="checkedId.includes(data.id)" [(ngModel)]="data.isRecheck" nzCheckedChildren="是" nzUnCheckedChildren="否"></nz-switch>
                    </td>
                </tr>
            </tbody>
        </nz-table>
    </div>
    <div nz-row style="margin-top: 10px;text-align: right;">
        <nz-pagination [(nzPageSize)]="pageSize" [(nzPageIndex)]="pageIndex" [nzTotal]="totalSize"
            [nzShowTotal]="totalTemplate" (nzPageIndexChange)="clickPage($event)"></nz-pagination>
        <ng-template #totalTemplate let-total> 总共 {{ totalSize }} 条 </ng-template>
    </div>
</div>